public class Test {
    public static void main(String[] args) {
        //
    }
}

class Solution {
    //二分查找
    public int findPeakElement(int[] nums) {
        int left = 0, right = nums.length - 1;
        while (left < right) {
            int mid = (left + right) / 2;
            if(nums[mid] > nums[mid + 1]){
                right = mid;
            }else{
                left = mid + 1;
            }
        }
        return left;
    }

    //暴力解法
    public int findPeakElement1(int[] nums) {
        //
        int index = 0;
        for (int i = 0; i < nums.length - 1; i++) {

            if (nums[i] > nums[i + 1]) {
                if(nums[i] > nums[i - 1]){
                    return index;
                }
            }


        }
        return index;
    }
}
